<!-- 表单弹窗 -->
<form id="taskComment-form" lay-filter="taskComment-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">评论人</label>
        <div class="layui-input-block">
            <input name="user" placeholder="" readonly type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论内容</label>
        <div class="layui-input-block">
            <input name="content" placeholder="" readonly type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">点赞数</label>
        <div class="layui-input-block">
            <input name="clikes" placeholder="" readonly type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">回复量</label>
        <div class="layui-input-block">
            <input name="creply" placeholder="" readonly type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论时间</label>
        <div class="layui-input-block">
            <input name="createTime" placeholder="" readonly type="text" class="layui-input"
                   lay-verify="required" required/>/
        </div>
    </div>
<!--    <div class="layui-form-item model-form-footer">-->
<!--        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>-->
<!--        <button class="layui-btn" lay-filter="taskComment-form-submit" lay-submit>回复</button>-->
<!--    </div>-->
</form>

<script>
    layui.use(['layer', 'admin', 'form', 'laydate', 'config'], function () {
        let layer = layui.layer;
        let admin = layui.admin;
        let form = layui.form;
        let laydate = layui.laydate;
        let config = layui.config;

        //开启公历节日
        laydate.render({
            elem: '#endtim'
            , calendar: true
            , trigger: 'click'
            , type: 'datetime'
        });

        // 填充表单数据
        // let pointsRuleType = $('#pointsRuleType')[0].options;
        // $("select[name='prtype']").append(pointsRuleType);
        let type = admin.getTempData('task_comment');
        if (type) {
            // $("input[name='prcode']").attr('disabled',true);
            form.val('taskComment-form', type);
        }
        form.render();

        // 表单提交事件
        form.on('submit(taskComment-form-submit)', function (data) {
            layer.load(2);
            console.log(JSON.stringify(data.field));
            if (data.field.id != null && data.field.id != '') {
                admin.req('api-task/taskComment/reply', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code === 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            } else {
                admin.req('api-task/taskComment/add', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code === 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            }
        });
    });
</script>
